package cn.iocoder.yudao.module.api.trade.order.dto;

import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.api.product.sku.dto.ProductPropertyValueRespDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * 订单项信息 Response DTO
 *
 * @author 山野羡民
 */
@Data
public class TradeOrderItemRespDTO {

    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long userId;

    @Schema(description = "店铺编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long shopId;

    @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long orderId;

    @Schema(description = "产品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long spuId;
    @Schema(description = "产品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
    private String spuName;

    @Schema(description = "产品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long skuId;

    @Schema(description = "产品 属性数组")
    private List<ProductPropertyValueRespDTO> properties;

    public List<ProductPropertyValueRespDTO> getProperties() {
        if (CollUtil.isEmpty(properties)){
            return List.of(ProductPropertyValueRespDTO.DEFAULT);
        }
        return properties;
    }

    @Schema(description = "产品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://exmaple.local/1.png")
    private String picUrl;

    @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer count;

    @Schema(description = "购买重量，单位：kg 千克", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
    private Double weight;

    @Schema(description = "计量单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "件")
    private String unitName;

    @Schema(description = "计量数值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer unitValue;

    @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    private Boolean commentStatus;

    @Schema(description = "产品原价（单）", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
    private Integer price;

    @Schema(description = "应付金额（总），单位：分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
    private Integer payPrice;

    @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
    private Integer pointPrice;

    @Schema(description = "使用的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
    private Integer deductPoint;

    @Schema(description = "联盟豆抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
    private Integer cryptocurrencyPrice;

    @Schema(description = "使用的联盟豆", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
    private Integer deductCryptocurrency;

    @Schema(description = "售后编号", example = "1024")
    private Long afterSaleId;

    @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer afterSaleStatus;

}
